<template>
  <div>
    <tablePaging :tableItem="tableItem" :operationItem="operationItem"/>
  </div>
</template>

<script setup>
import tablePaging from '@/views/common/component/table-paging'
import { onMounted, reactive, ref, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import {tableItem, operationItem, listFreeCourseApi} from './const.js'
import { ElMessage } from 'element-plus'
import { download } from "@/utils/request";
const router = useRouter()
const { proxy } = getCurrentInstance();
// 搜索
operationItem.menuArray[0].handle = () => {
  clickSearch()
}
// 导出
operationItem.menuArray[1].handle = () => {
  clickExport()
}
function clickSearch() {
  tableItem.pageInfo.paging()
}
function clickExport() {
  let url = '/sale/student/free/export'
  let fileName = '免费学员统计表'
  download(url, tableItem.pageInfo.request, fileName, {}, {})
}
//设置科目搜索栏可选性
function initCourseOptionsList() {
  operationItem.SearchItem[3].options = []
  listFreeCourseApi().then(res => {
    const freeCourseList = res.rows || []
    freeCourseList.map(item => {
      operationItem.SearchItem[3].options.push({ label: item.name, value: item.id })
    })
  })
}

onMounted(() => {
  initCourseOptionsList()
})

</script>
<style></style>
